package com.demo.apply.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.demo.apply.common.Result;
import com.demo.apply.dao.ApiMapper;
import com.demo.apply.dao.TDApplyMapper;
import com.demo.apply.model.TDApply;
import com.demo.apply.model.User;
import com.demo.apply.service.ApiService;
import com.demo.apply.service.ITDApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 申请表 服务实现类
 * </p>
 *
 * @author 
 * @since 2021-11-10
 */
@Service
public class ApiServiceImpl implements ApiService {


    @Autowired
    ApiMapper mapper;





    public Map getItemByParam(Map param) {
        return mapper.getItemByParam(param);
    }

    public void deleteItemsByParam(Map param) {
        List<String>ids= (List<String>) param.get("ids");
        String table = param.get("table").toString();
        mapper.deleteItemsByParam(table,ids);
    }


    @Override
    public Map<String, Object> getPageList(Map param) {
        Long totalCount=mapper.getTotalCount(param);
        List<Map<String,Object>> data=mapper.getMapListByParam(param);

        Map<String,Object>resultMap=new HashMap<>();
        resultMap.put("data",data);
        resultMap.put("count",totalCount);
        resultMap.put("code",0);
        resultMap.put("msg","ok");
        return resultMap;
    }

    @Override
    public List<Integer> getStatistics() {
        return mapper.getStatistics();
    }

    @Override
    public void addVisitLog(Map param) {
        mapper.addVisitLog(param);
    }
}
